<template>
	<view  class="order-detail">
		<u-cell-item title="基础信息" :arrow="false"></u-cell-item>
		<view class="o-d-base">
			<view>订单号：{{orderData.orderNo}}</view>
			<view class="u-flex">
				<view class="u-flex-1">
					订单状态：<text class="primary">{{orderStatusList[orderData.orderStatus]}}</text>
				</view>
				<view v-if="orderData.orderType != 2">
					<view v-if="orderData.orderStatus==2||orderData.orderStatus==3" class="primary" @click="viewwuliu()">查询物流</view>
				</view>
			</view>
			<view>门店名称：{{orderData.merchantName}}</view>
			<view>下单人手机号：{{orderData.userPhone}}</view>
			
			<view v-show="orderData.deliveryType==3" class="u-line-1">商家联系电话：<text class="primary">{{orderData.businessPhone || '暂无'}}</text></view>
			<view v-show="orderData.deliveryType==3" class="u-line-1">取货门店地址：<text class="primary">{{orderData.businessAddress || '暂无'}}</text></view>
			
			<view>购买数量：{{orderData.buyNumber}}</view>
			<view>优惠金额：￥{{orderData.discountAmount}}</view>
			<view>订单运费：￥{{orderData.freightAmount}}</view>
			<view>糖果平均价：￥{{orderData.sweetAveragePrice}}</view>
			<view>糖果抵扣的现金价：￥{{orderData.sweetDeductPrice}}</view>
			
			<view>实际支付金豆：{{orderData.actualPayGoldenBean}}</view>
			<view>实际应结算金豆数：{{orderData.actualSettledGoldenBean}}</view>
			<view>金豆平均价：{{orderData.goldenBeanAveragePrice}}</view>
			<view>金豆抵扣的现金价：{{orderData.goldenBeanDeductPrice}}</view>
			
			
			<view>总金额：￥{{orderData.totalAmount}}</view>
			<view>成本总价：￥{{orderData.totalCostAmount}}</view>
			<view>订单是否入账到商家：{{orderData.isAccounted?'是':'否'}}</view>
			<view>订单是否已申请售后：{{orderData.isAfterSale?'是':'否'}}</view>
			<view>下单时间：{{orderData.orderTime}}</view>
			<view>订单类型：{{orderTypeText[orderData.orderType]}}</view>
			<view>支付时间：{{orderData.paymentTime || '暂无'}}</view>
			<view>订单现金支付渠道：{{orderData.pricePayType==1?'微信':orderData.pricePayType==2?'支付宝':'银行卡'}}</view>
			<view>结算状态：<text class="primary">{{orderData.settleStatus==0?'未结算':'已结算'}}</text></view>
			<view v-show="orderData.settleStatus==1">结算时间：{{orderData.settleTime}}</view>
		</view>
		<u-gap height="14" bg-color="#F0F0F0"></u-gap>
		<u-cell-item title="商品信息" :arrow="false"></u-cell-item>
		<view v-for="(item,index) in mallData" :key="index">
			<view class="o-d-card u-flex">
				<image class="card-img" :src="item.productImageUrl" mode=""></image>
				<view class="u-flex-1" style="min-width:0">
					<view class="card-name u-line-1" style="font-size: 28rpx;">
						{{item.productName}}
					</view>
					<view>糖果抵扣价:{{item.sweetDeductPrice}}</view>
					<view>实际支付糖果：{{item.actualSweet}} </view>
					<view>实际支付金额：{{item.actualAmount}}</view>
					<view class="u-flex u-row-between primary" style="font-size: 30rpx;">
						<view class="u-flex-1">￥{{item.productUnitPrice}}</view>
						<view>x{{item.productUnit}}</view>
					</view>
				</view>
			</view>
			<view class="o-d-card-info hui">
				<view>商品货号:{{item.productCode}}</view>
				<view>规格属性:{{item.productSkuSpec}}</view>
			</view>
		</view>
		<u-gap height="14" bg-color="#F0F0F0"></u-gap>
		<u-cell-item v-if="orderData.orderType != 2" title="收货信息" :arrow="false"></u-cell-item>
		<view v-if="orderData.orderType != 2" class="o-d-base">
			<view>收货人姓名：{{orderData.deliveryName}}</view>
			<view>收货人电话：{{orderData.deliveryMobile}}</view>
			<view>物流公司：<text class="primary">{{orderData.courierName || '暂无'}}</text></view>
			<view>物流单号：<text class="primary">{{orderData.courierNo || '暂无'}}</text></view>
			<view>收货地址(详细地址)：{{orderData.deliveryStreet}}</view>
			<view>收货地址省市区：{{orderData.deliveryRegion}}</view>
			<view>发货时间：<text class="primary">{{orderData.deliveryTime || '暂无'}}</text></view>
			<view>取货方式：<text class="primary">{{orderData.deliveryType==1?'快递配送':orderData.deliveryType==2?'同城配送':orderData.deliveryType==3?'门店自提':''}}</text></view>
			<view>买家备注：{{orderData.memo}}</view>
		</view>
		<u-gap height="14" bg-color="#F0F0F0"></u-gap>
		<u-cell-item title="优惠券信息" :arrow="false" v-show="couponListVo"></u-cell-item>
		<view class="o-d-base" v-if="couponListVo != null || couponListVo">
			<view>优惠券名称：{{couponListVo.type}}</view>
			<view>类型：{{couponListVo.key=='plat_task_coupon'?'任务优惠卷轴':''}}</view>
			<view>抵扣金额：{{couponListVo.deductionPrice}}</view>
			<view>满减金额：{{couponListVo.minPrice}}</view>
		</view>
	</view>
</template>

<script>
	import dataJs from './data.js'
	export default {
		data() {
			return {
				orderNo: '',
				orderData: {},
				mallData: [],
				couponListVo: {},
				orderStatusList: {
					'0': '待付款',
					'1': '已付款',
					'2': '已发货',
					'3': '已确认',
					'4': '已取消',
					'5': '已退款'
				},
				orderTypeText: dataJs.orderTypeText,
			}
		},
		onLoad(option) {
			this.orderNo = option.id;
			this.getDetail()
		},
		methods: {
			viewwuliu() {
				let row = this.orderData;
				let product = this.mallData.length > 0 ? this.mallData[0] : {}
				uni.navigateTo({
					url: `./logisticsDetail?courierNo=${row.courierNo}&deliveryMobile=${row.deliveryMobile}&orderNo=${row.orderNo}&merchantName=${row.merchantName}&orderProductName=${product.productName}&totalAmount=${product.productUnitPrice}&orderProductImgUrl=${product.productImageUrl}`
				})
			},
			getDetail() {
				this.$u.api.getmallOrderDetails({
					orderNo: this.orderNo,
				}).then(res=>{
					if(res.code == 0){
						this.orderData = res.data.order;
						this.mallData = res.data.orderProduct;
						this.couponListVo = res.data.couponListVo || null;
					}else{
						uni.showToast({
							icon:'none',
							title: res.msg
						});
					}
				})
			}
		}
	}
</script>

<style scoped>
.primary {
	color: #357CD4;
}
.hui {
	color: #999999;
}
.o-d-base {
	padding: 25rpx 30rpx 20rpx 30rpx;
	font-size: 26rpx;
	line-height: 44rpx;
}
.card-img {
	margin-right: 30rpx;
	width: 166rpx;
	height: 166rpx;
	border-radius: 10rpx;
	font-size: 24rpx;
}
.o-d-card {
	padding: 23rpx 30rpx 20rpx 30rpx;
	font-size: 24rpx;
}
.o-d-card-info {
	padding: 0 30rpx 10rpx 30rpx;
	font-size: 24rpx;
}
</style>
